package 富婆梦.第一阶段.Java基础视频学习.线程的练习.练习;

/**
 * @ProjectName: java-learning
 * @Package: 富婆梦.第一阶段.线程的练习.练习
 * @ClassName: Exercise656
 * @Author: hemengjin
 * @Description: 实现一个Runable在run内部打印一个消息，让后调用yield，重复这个操作，然后从run()中返回
 * 在构造器中放置一条启动信息，并且放置一天任务终止时的关闭信息
 * @Date:2021/10/18 18:38
 * @Version: 1.0
 */
public class Exercise656 {
    public static void main(String[] args) {
        Exercise656 exercise656 = new Exercise656();
        for (int i = 0; i < 10; i++) {
            exercise656.action(i);
        }
    }

    public void action(int tag) {
        System.out.println("任务" + tag + "开始启动：");
        Thread thread = new Thread(new MyRunable());
        thread.start();
        System.out.println("任务" + tag + "结束！");
    }

    public class MyRunable implements Runnable {
        @Override
        public void run() {
            for (int i = 0; i < 3; i++) {
                System.out.println("听说你是大美女！");
                Thread.yield();
            }
        }
    }
}
